#include "Title.h"


bool Title::FINISH = false;
unsigned _stdcall Title::GetCode(void * argv) 
{
	std::string str;
	while(!FINISH)
	{
			if(GetAsyncKeyState(VK_UP)) //http://msdn.microsoft.com/en-us/library/ms645540%28VS.85%29.aspx
			{
				str += "u";
			}
			if(GetAsyncKeyState(VK_LEFT))
			{
				str += "l";
			}
			if(GetAsyncKeyState(VK_RIGHT))
			{
				str += "r";
			}
			if(GetAsyncKeyState(VK_DOWN))
			{
				str += "d";
			}
			if(GetAsyncKeyState(0x41))
			{
				str += "a";
			}
			if(GetAsyncKeyState(0x42))
			{
				str += "b";
			}
			if(GetAsyncKeyState(VK_RETURN))
			{
				str += "s";
			}
			if(str == "uuddlrlrabs")
			{
				Game_Settings::SNAKE_SIZE = 20;
				Game_Settings::MASTER_GAMESPEED = 120;
				Game_Settings::MASTER_GAME_LEVEL = 5;
				Game_Settings::MASTER_LEVEL_DIF = 2;
				cout << "\n\n\t\t\tKONAMI MODE ON";
				FINISH = true;
			}
			Sleep(250);
	}
	return 0;
};
void Title::Display()
{
	
	cout << "..............................................................................." << std::endl;
	cout << "..............................................................................." << std::endl;
	cout << "..............................................................................." << std::endl;
	cout << "......MMMMMMMM.....MMM.....MMM.......MMM.......MMM.....MMMM..MMMMMMMMMMM......." << std::endl;
	cout << ".....MMMM  MMMM...MMMMM....MMM......MMMMM......MMM...MMMM....MMMMMMMMMM........" << std::endl;
	cout << ". ...MMM....MMM...MMMMM....MM......MMMMMM.....MMM..MMMM......MMM..............." << std::endl;
	cout << ".....MMMMM........MM.MMM..MMM.....MMM..MM.....MMMMMMM.......MMMMMMMMMMM........" << std::endl;
	cout << ".......MMMMMM....MMM..MMM.MMM....MMM...MMM....MMMMMMMM......MMMMMMMMMM........." << std::endl;
	cout << ".... .....:MMM...MMM..MMM.MM....MMMMMMMMMM...MMMM...MMM.....MMM................" << std::endl;
	cout << "...MMM.....MMM...MMM...MMMMM...MMMMMMMMMMM...MMM....MMMM...MMM................." << std::endl;
	cout << "....MMMMMMMMMM..MMM.....MMMM..MMM......MMM...MMM.....MMMM..MMMMMMMMMMM........." << std::endl;
	cout << ".....MMMMMMM....MMM.....MMM..MMM........MMM.MMM.......MMM..MMMMMMMMMMM........." << std::endl;
	cout << "..............................................................................." << std::endl;
	cout << "..............................................................................." << std::endl;
	cout << "..............................................................................." << std::endl;
	cout << "..............................................................................." << std::endl;
	cout << "..............................................................................." << std::endl;
	cout << endl << endl << endl << endl;
	cout << "                         Developed by Matt Tondreau" << std::endl;
	cout << "                     2009 GNU General Public License v3" << std::endl;
	cout << "                    http://code.google.com/p/win32snake" << std::endl;

	Sleep(TITLE_DISPLAY_TIME );
	FINISH = true;
	ixion::SetCursorPos(26,19);
	cout << "PRESS ENTER TO CONTINUE";

}
void Title::title()
{
	unsigned int idThread; //id of thread
	unsigned long hThread = _beginthreadex(NULL,THREAD_SUSPEND_RESUME,GetCode,NULL, 0,&idThread);
	system("title Snake");
	Display();
	_getch();
}
